<!DOCTYPE html>
<html lang="en">
	<head>
		<title>Recaf - modern bytecode editor</title>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
		<meta name="viewport" content="width=device-width">
		<meta name="description" content="Recaf is a modern java bytecode editor using Objectweb's ASM and JavaFX.">
		<meta name="keywords" content="java,bytecode,editor,recaf,reverse engineering">
		<link rel="icon" type="image/x-icon" href="favicon.ico"/>
		<link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="css/code.css">
	</head>
	<body>
		<header>
			<div class="beam container-wide">
				<div class="box-left">
					<a href="index.html"><div class="logo"></div></a>
				</div>
				<div class="box-right">
					<nav>
						<a href="index.html">Home</a>
						<a href="documentation.html">Documentation</a>
						<a href="features.html">Features</a>
						<a href="https://github.com/Col-E/Recaf">Github</a>
					</nav>
				</div>
			</div>
		</header>
		<section id="content">
			<h1 id="summary">Summary</h1>
			<p>Plugins are modular components that extend Recaf's capabilities by using plugin api located in the package <span class="code">me.coley.recaf.plugin</span>.</p>
			<p>Plugins are distributed as jar files.</p>
			<h1 id="setup">Setup</h1>
			<p>To start developing a plugin, download the workspace from github <a href="https://github.com/Col-E/Recaf-plugin-workspace">here (Plugin maven workspace)</a>. Most IDE's should be capable of importing the <span class="code">pom.xml</span> into a maven project.</p>
			<ul>
				<li><a href="https://stackoverflow.com/a/36242422">Eclipse</a></li>
				<li><a href="https://www.jetbrains.com/help/idea/maven-support.html#maven_import_project_start">IntelliJ</a></li>
			</ul>
			<p>Make sure the project compiles. If you want to do this from your IDE you only need to specify the goal of <span class="code">package</span>.</p>
			<h1 id="expansion">Extension</h1>
			<p>This is what the plugin should look like at bare minimum:</p>
<pre><span class="line"></span><span class="keyword">package</span> me.yourname.pluginname;
<span class="line"></span>
<span class="line"></span><span class="keyword">import</span> org.plugface.core.annotations.Plugin;
<span class="line"></span><span class="keyword">import</span> me.coley.recaf.plugin.*;
<span class="line"></span>
<span class="line"></span><span class="annotation">@Plugin</span>(name = <span class="string">&quot;Example&quot;</span>)
<span class="line"></span><span class="keyword">public</span> <span class="keyword">class</span> ExamplePlugin <span class="keyword">implements</span> PluginBase {
<span class="line"></span>    <span class="annotation">@Override</span>
<span class="line"></span>    <span class="keyword">public</span> String name() {
<span class="line"></span>        <span class="keyword">return</span> <span class="string">&quot;Example&quot;</span>;
<span class="line"></span>    }
<span class="line"></span>
<span class="line"></span>    <span class="annotation">@Override</span>
<span class="line"></span>    <span class="keyword">public</span> String version() {
<span class="line"></span>        <span class="keyword">return</span> <span class="string">&quot;1.0&quot;</span>;
<span class="line"></span>    }
<span class="line"></span>    
<span class="line"></span>    <span class="annotation">@Override</span>
<span class="line"></span>    <span class="keyword">public</span> <span class="keyword">void</span> onLoad() {
<span class="line"></span>        <span class="comment-line">// Optional, but useful to show that it loads in the console output</span>
<span class="line"></span>        System.out.println(<span class="string">&quot;Hello&quot;</span>);
<span class="line"></span>    }
<span class="line"></span>}
</pre>
			<p>Plugins by default only need the <span class="code">name</span> and <span class="code">version</span> methods, but with additional interface implmentations extra functionality can be added.</p>
			<p><b>Launchable</b> allows access to command-line arguments. The following classes are found in the <span class="code">me.coley.recaf.plugin</span> package</p>
<pre><span class="line"></span><span class="keyword">import</span> javafx.application.Application.Parameters;
<span class="line"></span>
<span class="line"></span><span class="comment-javadoc">/** Interface applied to plugins that have access to the launch arguments. */</span>
<span class="line"></span><span class="keyword">public</span> <span class="keyword">interface</span> Launchable {
<span class="line"></span>    <span class="comment-javadoc">/**
<span class="line"></span>     * Called before the paramaters are parsed internally by Recaf.
<span class="line"></span>     */</span>
<span class="line"></span>    <span class="keyword">void</span> preparse(String[] args);
<span class="line"></span>
<span class="line"></span>    <span class="comment-javadoc">/**
<span class="line"></span>     * Called after the paramaters are parsed internally by Recaf.
<span class="line"></span>     */</span>
<span class="line"></span>    <span class="keyword">void</span> postparse(String[] args);
<span class="line"></span>}
</pre>
			<p><b>Stageable</b> allows the plugin to be shown in the plugins drop-down menu. Clicking the plugin name in the drop-down will open a window with the content you supply.</p>
<pre><span class="line"></span><span class="comment-javadoc">/** Interface applied to plugins that will be shown in 
<span class="line"></span> *  the menu-bar under the &quot;plugins&quot; menu. */</span>
<span class="line"></span><span class="keyword">public</span> <span class="keyword">interface</span> Stageable {
<span class="line"></span>    <span class="comment-javadoc">/** @return Content of stage to create. */</span>
<span class="line"></span>    Parent content();
<span class="line"></span>
<span class="line"></span>    <span class="comment-javadoc">/** @return Title of stage to create. */</span>
<span class="line"></span>    String title();
<span class="line"></span>
<span class="line"></span>    <span class="comment-javadoc">/** @return Width of stage to create. */</span>
<span class="line"></span>    <span class="keyword">int</span> width();
<span class="line"></span>
<span class="line"></span>    <span class="comment-javadoc">/** @return Height of stage to create. */</span>
<span class="line"></span>    <span class="keyword">int</span> height();
<span class="line"></span>
<span class="line"></span>    <span class="comment-line">// default methods ommited, check src for </span>
<span class="line"></span>    <span class="comment-line">// optional methods to override</span>
<span class="line"></span>}
</pre>
			<h1 id="exporting">Exporting</h1>
			<p>The plugin API works via simple annotation-based jar loading. To compile your plugin use maven <span class="code">mvn package</span>. This will generate a jar file in the <span class="code">target</span> directory. Copying this file into Recaf's <span class="code">plugins</span> folder will install it. Launch Recaf to verify that your plugin does indeed load.</p>
			<h1 id="examples">Examples</h1>
			<p>For examples implmentations of the plugin api check out these sample plugins:</p>
			<ul>
				<li><a href="https://github.com/Col-E/Recaf-plugin-workspace/releases/tag/example-mal-scan2">Malicious code scanner</a></li>
			</ul>
		</section>
	</body>
</html>